using Microsoft.Office.Interop.Excel;

namespace ExcelRefresh.Excel
{
    public static class WorkbookExtensions
    {
        #region Get and Set Custom Document Properties

        public static void SetDocumentProperty(this Workbook book, string propertyName, string propertyValue)
        {
            var custProps = (ICustomProperties)book.CustomDocumentProperties;
            custProps.Add(propertyName, propertyValue);
        }

        private static dynamic GetDocumentProperty(this Workbook book, string propertyName)
        {
            var custProps = (ICustomProperties)book.CustomDocumentProperties;
            var prop = custProps[propertyName];
            if(prop != null)
                return prop.Value;
            return null;
        }
        #endregion
    }
}